#include "StdAfx.h"
#include "CityBusInfo.h"
#include "BusLineInfo.h"
#include "StationInfo.h"
#include "StringDic.h"
CCityBusInfo::CCityBusInfo(void)
{
}


CCityBusInfo::~CCityBusInfo(void)
{
	if(m_vecAllStationInfo.size() > 0)
	{
		delete[]  m_vecAllStationInfo[0];
		m_vecAllStationInfo.clear();
	}
	//for(vector<CStationInfo *>::iterator ite = m_vecAllStationInfo.begin(); ite != m_vecAllStationInfo.end();++ite)
	//{
	//	if(*ite)
	//		delete *ite;
	//}
	
	//for(vector<CBusLineInfo *>::iterator ite = m_vecAllBusLineInfo.begin(); ite != m_vecAllBusLineInfo.end();++ite)
	//{
	//	if(*ite)
	//		delete *ite;
	//}
	if(m_vecAllBusLineInfo.size() > 0)
	{
		delete[]  m_vecAllBusLineInfo[0];
		m_vecAllBusLineInfo.clear();
	}
	

}


void  CCityBusInfo::AddBusLine( CBusLineInfo *pBusLineInfo )
{
	//assert(pBusLineInfo);
	m_vecAllBusLineInfo.push_back(pBusLineInfo);
}

void CCityBusInfo::AddStationInfo( CStationInfo *pStationInfo )
{
	m_vecAllStationInfo.push_back(pStationInfo);
}

void CCityBusInfo::Init(const char *pszCityName,unsigned short BusLineCount,unsigned short StationsCount)
{
	SetName(pszCityName);
	CStationInfo *parrStation = new CStationInfo[StationsCount];
	
	if(StationsCount > 0)
	{
		for(int i=0;i<StationsCount;++i)
			AddStationInfo(&parrStation[i]);

	}
	
	if(BusLineCount > 0)
	{
		CBusLineInfo *parrLine = new CBusLineInfo[BusLineCount];
		for(int i=0;i<BusLineCount;++i)
			AddBusLine(&parrLine[i]);
	}

}
